package com.lt.exam.ZhuangShiQi;

import com.lt.exam.Yao.Yao;
import com.lt.exam.Yao.YaoMap;

import java.util.List;
import java.util.Map;

/**
 * @author LT
 * @version 1.0
 * @PackageName com.lt.exam.ZhuangShiQi
 * @ClassName BingLiZhuangShiQi
 * @Description to do
 * @date 2021/12/1 16:15
 */
public abstract class BingLiZhuangShiQi implements BingLi{
    //被装饰的病例
    public BingLi bingli = null;
    //存放药物实体类的map映射
    private Map<String, Yao> yaoMap = YaoMap.getYaoMap();

    public Map<String, Yao> getYaoMap() {
        return yaoMap;
    }
    public BingLiZhuangShiQi(BingLi bingli) {
        this.bingli = bingli;
    }
    @Override
    public String toString() {
        return  this.getDescription() ;
    }

    @Override
    public void printList() {
        for (Yao yao :getList()){
            if (yao.getPrice() != 0.0) {
                System.out.println(yao);
            }
        }
    }
    @Override
    public void add(Yao yao) {
        bingli.getList().add(yao);
    }

    @Override
    public void delete(Yao yao) {
        List yaoList=bingli.getList();
        if (yaoList.contains(yao)){

            yaoList.remove(yao);
        }
    }
}
